import React, { Component } from 'react'
import Grid from 'components/grid/Grid'
import { get } from 'api/http'
import "./HotCate.style.scss"
import {withRouter} from 'react-router-dom'

 class HotCate extends Component {
  state={
    datalist:[]
  }

  render() {
    return (
      <div className="hotcate">
        <h2>
          热门分类
        </h2>
        <Grid  list={this.state.datalist}
          itemClick={()=>{
            console.log(this.props)
            this.props.history.push('/list')
          }}
          imgRadius={0.08} column={4}
          renderTitle={(item) => {
          return <p>{item.title}</p>
          }}
        ></Grid>
      </div>
    )
  }


  async componentDidMount() {
    let rs = await get('/api/hotcat')
    this.setState({
      datalist:rs.data
    })
  }

}

export default withRouter(HotCate)
